<?php
/**
 * Copyright (C) 2013 Pablo Sepúlveda P. <psep.pentauc@gmail.com>
 * 
 * This file is part of gAbstract.
 * WarpIT is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 * 
 * gAbstract is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with gAbstract.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * Esta clase define los Parámetros del
 * preparedstatement en la query.
 * 
 * @author psep
 * @version 1.0
 * @package gAbstract
 * @copyright Copyright (c) 2013 Pablo Sepúlveda P.
 * @license GNU GPLv3 or later
 * @link http://www.psep.cl
 */
class ParameterBean {
	
	/**
	 * Atributo mixto de valor para query.
	 * 
	 * @var mixed Object
	 */
	private $value;
	
	/**
	 * Atributo que define el tipo de parámetro
	 * para la definición del statement en la abstracción.
	 * 
	 * @var Integer type.
	 */
	private $type;
	
	/**
	 * Método que retorna el valor definido.
	 * 
	 * @return mixed Object $value
	 */
	public function getValue(){
		return $this->value;
	}
	
	/**
	 * Método Setter para el atributo value.
	 * 
	 * @param mixed Object $value
	 */
	public function setValue($value){
		$this->value = $value;
	}
	
	/**
	 * Método que retorna el atributo type,
	 * que determina el tipo de atributo
	 * value para el statement.
	 * 
	 * @return Integer type.
	 */
	public function getType(){
		return $this->type;
	}
	
	/**
	 * Método para cargar el tipo del valor
	 * para ser cargado en el statement. Por
	 * defecto nada será cargado.
	 *
	 * 1 = Boolean
	 * 2 = Null
	 * 3 = Integer
	 * 4 = String
	 * 5 = SQL Date
	 * 
	 * @param Integer $type
	 */
	public function setType($type){
		$this->type = $type;
	}
	
	/**
	 * Método que retorna el objeto PDO::PARAM_**
	 * dependiendo del tipo ingresado.
	 * 
	 * @return PDO::PARAM_** Object
	 */
	public function getObjParam(){
		switch ($this->type) {
			case 0: return PDO::PARAM_BOOL;	break;
			case 1: return PDO::PARAM_NULL;	break;
			case 2: return PDO::PARAM_INT;	break;
			case 3: return PDO::PARAM_STR;	break;
			case 4: return PDO::PARAM_LOB;	break;
			default: return null; break;
		}
	}
	
}


?>